<template>
	<view class="">
		<view class="topinput">
			<input type="text" placeholder="搜索" v-model="filterText">
			<select v-model="selectdata">
				<option value=''>仓库名称</option>
				<option>仓库地址</option>
			</select>
		</view>
		<view class="box" v-for="(item,index) in filterList" :key="index" @click="topage(item.wname,item.wid)">
			<view class="boxcent">
				<view class="topcent">
					<text class="text">仓库名称:</text>
					<text class="text1">{{item.wname}}</text>
				</view>
				<view class="headcent">
					<view class="tophead">
						<text class="text">仓库编号:</text>
						<text class="text1">{{item.wid}}</text>
					</view>
					<view class="head">
						<text class="text">仓库地址:</text>
						<text class="text1">{{item.adress}}</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list:[],selectdata:'',filterText:'',stoname:'',supname:''
			}
		},
		computed: {
			filterList() {
				let selectdata = this.selectdata;
				var arr = []
				this.list.forEach((item) => arr.push(item))	
				if (this.filterText) {
					if(selectdata==''){
						arr = this.list.filter(item => item.wname.includes(this.filterText))
					}else if(selectdata=='仓库地址'){
						arr = this.list.filter(item => item.adress.includes(this.filterText))
					}	
				}
				return arr
			}	
		},
		onLoad: function (option) {
			this.stoname = option.stoname;
			this.supid = option.supid
			this.getdata();
		},
		methods: {
			async getdata(){
				const res1 = await this.Request({
					url:'/api/warehouse/getwardata'
				})
				this.list = res1.data;
			},
			topage(wname,wid){
				var pages = getCurrentPages();
				var prePage = pages[pages.length - 2]; //上个页面
				prePage.warnewname=wname;  //赋值值
				prePage.warnewid=wid;  //赋值值
				uni.navigateBack({
					delta: 1
				});
			}
		}
	}
</script>

<style lang="scss">
	.topinput{
			display: flex;
			input{
				height: 30px;
				width: 200px;
				margin: 15px 0 15px 20px;
				border-radius: 10px;
				border: 2px solid #919191;
			}
			select{
				margin: 15px 0 15px 30px;
				border-radius: 10px;
			}
	}
	.boxcent{
		position: relative;
		width: 100%;
		background-color: #ffff7f;
		border: 1px solid  #ccc;
		border-radius: 10px;
		.text1{
			font-size: 14px;
			margin-left: 7px;
		}
		.topcent{
			display: flex;
			margin: 10px 0 0 40px;
			.text{
				font-size: 17px;
				font-weight: 700;
			}
			.head{
				position: absolute;
				margin-left: 162px;
				.text{
					font-size: 15px;
					font-weight: 500;
				}
			}
		}
		.headcent{
			margin: 15px 0 5px 40px;
			display: flex;
			.tophead{
				.text{
					font-size: 15px;
					// font-weight: 500;
				}
			}
			.head{
				margin-left: 27px;
				.text{
					font-size: 15px;
					// font-weight: 500;
				}
			}
		}
	}
	.box :active{
		background-color: #ffffff;
	}
</style>